5. how to use global variables
你好。
Hello.
在本教程中,我们将学习。
In this tutorial, we will learn.
全局变量定义,那是什么?
Global variable definition, what is that?
在这里,您可以看到我们使用的零或我们使用零的原因,但这些节拍或这些输出或内部关联上没有标签。
Here you can see zero that we used or why zero we used, but there is no label on these beats or on these outputs or internal relates.
另外,在 A C 编程区域,我们没有对我的 N5 或 M6 设备使用任何注释或标签。
Also, in the A C programming area, we didn't use any comment or label with my N5 or M6 devices.
所以。
So.
我需要知道使用的是哪个设备,例如这是M0。
I need to know which device is used, for example, this is M0.
它可以是零,这可以是紧急停止按钮,它是一,例如,启动按钮 X2 可以是,例如,停止按钮,就像在左侧,您将看到标签下方的标签,您将查看全局标签,在其下方您将看到全局左侧。
It can be it's zero and this can be emergency stop button and it's one is, for example, start button X2 can be, for example, stop button and like that into the left side, you will see the label under the label, you will see the global label and under it you will see the global left.
点击那个。
Click to that.
然后您将看到标签名称和数据类型以及来自外部设备的访问。
And then you will see the label name and data type and access from external device.
现在我们有什么?
And now what we have?
例如,我们在这里定义一个标签名称。
Let's define here a label name, for example.
开始按钮。
Start button.
好的。
OK.
像这样,它需要定义一个数据类型,并且要构建数据类型。
Like that, and it needs to define a data type and data type is going to be built.
让我们从这里找到一份账单。
And let's find a bill from here.
字和双字,而不是定时器。
Word and double word and not a timer.
还算可以吧。
It is a bit OK.
这有点Bill的意思,例如,在这里我将定义我的停止按钮。
This is a bit means Bill, and for example, into here I will define my stop button.
这也将是。
And this is going to be also.
打。
Beat.
好的。
OK.
一切准备就绪。
And it's ready.
例如,作为输出电机前进。
And for example, as output motor forward.
好的。
OK.
这也将是。
And this is going to be also.
击败并变成编程区,它有一个程序,伙计。
Beat and turned into programming area, and it's got a program, buddy.
在这一点上,我会写,例如。
And at this point, I will write, for example.
现在你会看到它处于精细模式。
Now you will see it's in the fine mode.
我们需要走到最右边。
We need to go to rightmost.
首先,让我们进一步完善它。
Firstly, let's go to make it right more.
此时,我将只写开始。
And at this point, I will just write start.
按钮,然后突然您会看到开始按钮,账单现在处于活动状态,我将单击此处,我只会说,好的,那么现在有什么变化?
Button and then suddenly you will see start button a bill is active now I will click to here and I will just say, OK, then what is change now?
您会看到我们正在使用 M 零、一、零或 y 零运行。
You will see we were running with the M zero or a one or a zero or y zero.
但现在我们正在使用字母或单词开始按钮以及此处的 LDI。
But now we are working with the letters or words start button and here LDI.
停止按钮,让我们选择。
Stop button and let's selected.
我会选择它,好的,好的,然后,如果开始这个过程而不停止,就会受到赞扬,并且它的古老座右铭会继续下去。
I will select it, OK and OK, then if start this process and not stop is praised and its old motto forward OK.
使用名称或标签编写策略程序很容易,我们将尝试它。
And it is easy to write a policy program with the name or the labels, and we will taste it.
但全球性意味着它可以是本地化的。
But the global means it can be local.
本地意味着我们有一个程序 pulehu,我们有一个程序,我们有一个警报部分和程序。
Local means we have a program pulehu and we have a program and we have an alarm section and program.
但是,如果我们在程序中创建一个本地标签,将其正文到程序中,则将您拉到此部分。
But if we create a local label into program, body it in program, pull you at this section.
它不能在这里大面积使用,但是如果我们创建一个全局变量,这个全局变量就可以在任何一个部分、任何地方使用,好吗?
It cannot be used in here in a large section, but if we create a global variable, this global variable can be used at any section and everywhere, OK?
例如,这里使用开始按钮。
For example, the use start button here.
另外,我们可以通过 if start 按钮在程序中使用 Start 按钮,因为这是全局变量。
Also, we can use the Start button in program by the if start button because of this is the global variable.
然后我们就可以在别的板块或者别的板块使用了,OK。
Then we can use in another section or another section, OK.
我们所拥有的,我们创建了全局变量以及我们创建了多少树时间。
And what we have, we created the global variables and how many tree time we created.
现在我们可以品尝它了。
And then now we can taste it.
但在我重建一切之前。
But before I will rebuild all.
这意味着我正在转换一个项目,没有问题,或者现在出现错误,我们现在可以进入模拟器。
And that means I am converting a project and there is no problem or there is now error and we can go to simulator now.
现在,模拟器已启动。
Now, Simulator is started.
我只会说“关闭”和“现在开始”按钮,我们可以等待观看窗口。
I will just say close and now start button, we can wait to watch window.
好的,然后我们可以激活“开始”按钮,您将看到这个标签。
OK, then we can activate the Start button and you will see this label.
该全局变量触点现在处于活动状态,而不是停止按钮,您将看到电机正向输出现已激活。
This global variable contact is now active and not stop button, and you will see motor forward output is now activated.
好的。
OK.
这就是我们怎样才能创建一个全球标签呢?
This is how can we create a global label?
我们如何在我们的政策项目中使用全球标签?
And how can we use a global label inside our policy projects?
本教程到这里就结束了。
For this tutorial, I'm finished here.
音频见。
See you into an audio.